package com.efesco.service.batchAdjust;

import com.bstek.dorado.data.*;
import com.bstek.dorado.data.db.DBStatement;
import com.bstek.dorado.utils.variant.VariantSet;
import com.bstek.dorado.common.*;
import com.bstek.dorado.common.rtexpr.impl.ExpressionUtils;
import com.efesco.common.*;

/**
 * ZongheYearlyAdjust_datasetAdjustListener
 */
public class ZongheYearlyAdjust_datasetAdjustListener extends AbstractDatasetListener {
  public void afterLoadData(Dataset dataset)
     throws Exception {
	  String theYear=ExpressionUtils.getInstance().getDate("yyyy");
	  String theMonth=AdjustBusiness.townAnnAdjustDate.substring(0,2);
	  String yearMonth=theYear+theMonth;
	  DBStatement state=new DBStatement(); 
	  String sql="select price from s_product_price where effect_start_month='"+yearMonth+"' "
	            +"and (effect_stop_month is null or effect_stop_month>='"+yearMonth+"') "
	            +"and product_id in(select p.product_id from s_product p,s_product_type pt where p.product_type_id=pt.product_type_id  and pt.type_category="+FinalDefine.ptCategory_ZONGHE+")";
	  state.setSql(sql);
	  VariantSet var=state.query();
	  state.close();
	  System.out.println("ddd"+sql);
	  dataset.insertRecord();
	  if(var!=null){
		  dataset.setValue("the_price",var.getValue(0));
	  }
  }

}
